
PM_FUNC_NORM_ATTRIB SaveNameSlot( String:szSave[], Int:iLen, Int:iPokeNum )
{
	formatex( szSave, iLen, "Poke%d", iPokeNum );
}
PM_FUNC_NORM_ATTRIB SaveNameBoxSlot( String:szSave[], Int:iLen, Int:iBoxNum, Int:iPokeNum )
{
	formatex( szSave, iLen, "Box%d:%d", iBoxNum, iPokeNum );
}

PM_FUNC_NORM_ATTRIB SavePlayerPokemon( Int:iPlayer, String:szSave[], String:szPokeName[], Int:iPokemonStats[ PM_POKESTAT ], POKESKILL:iPokemonSkills[ SKILLS_PER_POKEMON ], Int:iSkillPPs[ SKILLS_PER_POKEMON ], String:szOwnerName[ NAME_LEN ] )
{
	pokemod_funcstart_debug( "SavePlayerPokemon %s", szSave );

	new String:szPlayerFile[ 64 ];
	nfv_player_file( iPlayer, szPlayerFile, charsmax( szPlayerFile ) );

	new String:szSkillSlotName[32], String:szSkillSlotPP[32];

	nfv_set_data( szPlayerFile, szSave, "Name", szPokeName );
	nfv_set_data( szPlayerFile, szSave, "OriginalOwner", szOwnerName );

	for ( new Int:iSkillNum; iSkillNum < SKILLS_PER_POKEMON; iSkillNum++ )
	{
		formatex( szSkillSlotName, charsmax(szSkillSlotName), "Skill%dName", iSkillNum );
		formatex( szSkillSlotPP, charsmax(szSkillSlotPP), "Skill%dPP", iSkillNum );

		if ( iPokemonSkills[ iSkillNum ] == SKILL_INVALID )
		{
			nfv_take_data( szPlayerFile, szSave, szSkillSlotName );
			nfv_take_data( szPlayerFile, szSave, szSkillSlotPP );
		}
		else
		{
			nfv_set_data( szPlayerFile, szSave, szSkillSlotName, SkillToName( iPokemonSkills[ iSkillNum ] ) );
			nfv_set_num( szPlayerFile, szSave, szSkillSlotPP, iSkillPPs[ iSkillNum ] );
		}
	}

	for ( new PM_POKESTAT:iStatNum; iStatNum < PM_POKESTAT; iStatNum++ )
	{
		//Skip Pokemon ID, we will save it after this
		if ( iStatNum == POKESTAT_POKEMON )
			continue;

		nfv_set_num( szPlayerFile, szSave, gPokeStatNames[ iStatNum ], iPokemonStats[ iStatNum ] );
	}

	//Overwrite the Pokemon ID with Pokemon Name, incase IDs change from the server adding new pokemon
	nfv_set_data( szPlayerFile, szSave, gPokeStatNames[ POKESTAT_POKEMON ], PokeToName( iPokemonStats[ POKESTAT_POKEMON ] ) );

	pokemod_funcend_debug( "SavePlayerPokemon" );
}

PM_FUNC_NORM_ATTRIB SavePlayerPokeSkill( Int:iPlayer, Int:iPokeNum, Int:iSkillNum )
{
	pokemod_funcstart_debug( "SavePlayerPokeSkill" );

	new String:szPlayerFile[ 64 ];
	nfv_player_file( iPlayer, szPlayerFile, charsmax( szPlayerFile ) );

	new String:szPokeSlot[32], String:szSkillSlotName[32], String:szSkillSlotPP[32];
	SaveNameSlot( szPokeSlot, charsmax(szPokeSlot), iPokeNum );
	formatex( szSkillSlotName, charsmax(szSkillSlotName), "Skill%dName", iSkillNum );
	formatex( szSkillSlotPP, charsmax(szSkillSlotPP), "Skill%dPP", iSkillNum );

	new POKESKILL:iSkillID = g_iPlayerPokemonSkills[ iPlayer ][ iPokeNum ][ iSkillNum ];
	if ( iSkillID == SKILL_INVALID )
	{
		nfv_take_data( szPlayerFile, szPokeSlot, szSkillSlotName );
		nfv_take_data( szPlayerFile, szPokeSlot, szSkillSlotPP );
	}
	else
	{
		nfv_set_data( szPlayerFile, szPokeSlot, szSkillSlotName, SkillToName( iSkillID ) );

		new Int:iSkillPP = g_iPlayerSkillPP[ iPlayer ][ iPokeNum ][ iSkillNum ];
		nfv_set_num( szPlayerFile, szPokeSlot, szSkillSlotPP, iSkillPP );
	}

	pokemod_funcend_debug( "SavePlayerPokeSkill" );
}

PM_FUNC_NORM_ATTRIB SavePlayerPokeStat( Int:iPlayer, Int:iPokeNum, PM_POKESTAT:iStatNum )
{
	pokemod_funcstart_debug( "SavePlayerPokeStat" );

	new String:szPokeSlot[32];
	SaveNameSlot( szPokeSlot, charsmax(szPokeSlot), iPokeNum );

	player_set_num( iPlayer, szPokeSlot, gPokeStatNames[ iStatNum ], g_iPlayerPokemonStats[ iPlayer ][ iPokeNum ][ iStatNum ] );

	pokemod_funcend_debug( "SavePlayerPokeStat" );
}




